var a = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), e = require("../../../@babel/runtime/helpers/asyncToGenerator"), t = require("../../../@babel/runtime/helpers/defineProperty"), r = getApp();

Page({
    data: {
        active: 0,
        codeShow: !1,
        pictureShow: !1,
        pictureList: [],
        titleArr: [ {
            code: "all",
            name: "全部订单"
        }, {
            code: "waitPay",
            name: "待支付"
        }, {
            code: "waitWorker",
            name: "待分配"
        }, {
            code: "waitTake",
            name: "待取货订单"
        }, {
            code: "waitDeliveryPay",
            name: "待到付订单"
        }, {
            code: "waitInstall",
            name: "待安装订单"
        }, {
            code: "isFinish",
            name: "已完成订单"
        }, {
            code: "refund",
            name: "售后订单"
        } ],
        custom_name: "",
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(a) {
        a.status && this.setData({
            active: Number(a.status)
        }), this.getListData();
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function() {
        var a = this;
        this.initData();
        var e = this.data, n = e.titleArr, o = e.active, i = e.page, d = {
            code: n[o].code,
            page: i
        }, s = r.getNetAddresss("plugin.live-install.frontend.order.orderList");
        r._postNetWork({
            url: s,
            data: d,
            success: function(e) {
                var n = e.data;
                if (1 != n.result) return r.tips(n.msg);
                a.data.total_page = n.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                n.data.another_name && n.data.another_name.plugin_name && wx.setNavigationBarTitle({
                    title: n.data.another_name.plugin_name
                }), a.setData({
                    custom_name: n.data.another_name.custom_name || "安装",
                    listData: n.data.data,
                    networkLoading: !0
                }), a.data.titleArr.forEach(function(e, r) {
                    "waitInstall" == e.code && a.setData(t({}, "titleArr[" + r + "].name", "待".concat(a.data.custom_name, "订单")));
                }), console.log(n);
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = this.data, t = e.titleArr, n = e.active, o = e.page, i = {
                code: t[n].code,
                page: o
            }, d = r.getNetAddresss("plugin.live-install.frontend.order.orderList");
            r._postNetWork({
                url: d,
                data: i,
                success: function(e) {
                    var t = e.data;
                    if (a.data.isLoadMore = !0, 1 === t.result) {
                        var r = a.data.listData.concat(t.data.data);
                        a.setData({
                            listData: r
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    gotoDetails: function(a) {
        var e = a.currentTarget.dataset.order_id;
        wx.navigateTo({
            url: "/packageH/installationSever/installationSeverRefund/installationSeverRefund?order_id=" + e
        });
    },
    onReady: function() {},
    bindBtnClick: function(t) {
        var n = this;
        return e(a.default.mark(function e() {
            var o, i, d;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    if (o = t.currentTarget.dataset, i = o.btn, d = o.order_id, "orderClose" != i.code) {
                        a.next = 7;
                        break;
                    }
                    return a.next = 4, r.confirm("是否确定".concat(i.name));

                  case 4:
                    if (0 != a.sent) {
                        a.next = 7;
                        break;
                    }
                    return a.abrupt("return");

                  case 7:
                    "orderPay" == i.code ? wx.navigateTo({
                        url: "/packageD/buy/orderPay/orderPay?order_id=" + d + "&status=2"
                    }) : "comment" == i.code ? wx.navigateTo({
                        url: "/packageD/member/myEvaluation/myEvaluation"
                    }) : "orderApplyRefund" == i.code ? wx.navigateTo({
                        url: "/packageD/member/myOrder/refund/refund?type=1&refundType=installationSever&order_id=" + d
                    }) : "orderClose" == i.code && n.cancelOrder(d), console.log(i);

                  case 9:
                  case "end":
                    return a.stop();
                }
            }, e);
        }))();
    },
    cancelOrder: function(a) {
        var e = r.getNetAddresss("order.operation.close");
        r._postNetWork({
            url: e,
            data: {
                order_id: a
            },
            success: function(a) {
                var e = a.data;
                if (1 != e.result) return r.tips(e.msg);
                wx.navigateBack();
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    bindChangeActive: function(a) {
        this.setData({
            active: a.detail.index
        }), this.getListData();
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});